<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/theme/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/bootstrap/css/bootstrap-table.min.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/theme/bootstrap-responsive.css" /> 
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/theme/style.css" />
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/theme/bootstrap.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap/bootstrap-table.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap/bootstrap-table-locale-all.min.js"></script> 
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/layerui/layer.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/layerui/layer.ext.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/skin/css/mobilecss/charge.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/skin/css/mobilecss/main.css">
    
    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }
    </style>
</head>
<body>

<div class="alert" id="alertDivId" style="display: none;z-index: 100; padding-right: 5px;padding-top: 0px;">
        <div >
            <p>昵称：<span id="niceName"></span></p>
            <p>游戏ID：<span id="niceName"></span></p>
            <p>原邀请人游戏ID：<span id="gameId"></span></p>
            <p>新邀请人游戏ID绑定：<input style="width: 108px" id="pgameId" type="text"></p>
            <input type="hidden" id="user_Id" name="user_Id" >
            <div>
                <button id="ok" onclick="confirmAgentClick()">确认绑定</button>
                <button style="background-color: #666;margin-left: 5%" id="close" onclick="closeAlertClick()">取消</button>
            </div>
        </div>
    </div>


<form class="form-inline definewidth m20" action="index.html" method="get">  
   <table>
	<tr>
	<td align="right">
	    邀请码：
	   <input type="text" name="code" style="width: 80px;height: 30px" id="code"class="abc input-default" placeholder="" value="">&nbsp;
	</td> 
	<td align="left">
	    游戏ID：
	   <input type="text" name="uid" style="width: 80px;height: 30px" id="uid"class="abc input-default" placeholder="" value="">
	</td>
	 </tr> 
	 <tr>
	 <td align="right">
	    姓&nbsp;名：
	    <input type="text" name="realname" style="width: 80px;height: 30px" id="realname"class="abc input-default" placeholder="" value="">&nbsp;
	 </td>
	 <td align="left"> 
	    手机号：
	    <input type="text" name="uphone" style="width: 80px;height: 30px" id="uphone"class="abc input-default" placeholder="" value="">&nbsp;
	    <button type="button" onclick="query()" class="btn btn-primary">查询</button>
	 </td>  
	 </tr> 
	</table>
</form>
 <table id="mytab" class="table table-striped table-bordered"></table> 
 <br>
</body>
<script>
	
	function query() {
		var code = $('#code').val();
	    var uid = $('#uid').val();
	    var realname = $('#realname').val();
	    var uphone = $('#uphone').val();
	    $('#mytab').bootstrapTable("refreshOptions", {
	        queryParams: function (params) {
	            params.numPerPage = params.limit;
	            params.pageNum = params.offset / params.limit + 1;
	            params.code = code;
	            params.uid = uid;
	            params.realname = realname;
	            params.uphone = uphone;
	            return params;
	        }
	    });
	    $('#mytab').bootstrapTable({
	        url: "${pageContext.request.contextPath}/admin/user_parent_mobile_data.html", //数据源
	       // height:tableHeight(),
	        dataField: "rows", //服务端返回数据键值 就是说记录放的键值是rows，分页时使用总记录数的键值为total
	        pagination: true, //是否分页
	        pageSize: 10, //单页记录数
	        pageList : [10,20,50,100,200 ],//分页步进值
	        sidePagination: "server", //服务端分页
	        contentType: "application/x-www-form-urlencoded", //请求数据内容格式 默认是 application/json 自己根据格式自行服务端处理
	        dataType: "json", //期待返回数据类型
	        method: "post", //请求方式
	        searchAlign: "left", //查询框对齐方式
	        locale: "zh-CN",
	        queryParams: function (params) {
	                params.numPerPage = params.limit;
	                params.pageNum = params.offset / params.limit + 1;
	                params.code = code;
		            params.uid = uid;
		            params.realname = realname;
		            params.uphone = uphone;
	                return params;
	            },
	            buttonsAlign: "left", //按钮对齐方式
	            paginationHAlign:"left",
	        columns: [
			{
			    field: "nickname",
			    title: "昵称",
			},{
	            field: "uid",
	            title: "玩家ID",
	        },{
			    field: "realname",
			    title: "姓名",
			},{
	            field: "uphone",
	            title: "手机号",
	        },{
	            field: "wechat",
	            title: "微信",
	        },{
	            field: "code",
	            title: "邀请码",
	        },{
	            field: "parent_nub",
	            title: "会员数",
	        },{
	            field: "parent_vip_nub",
	            title: "下级推广员数",
	        },{
	            field: "createTime",
	            title: "注册时间",
	        },{
	        	width: "10%",
	            field: "freeze",
	            title: "状态",
	            formatter: function (value, row, index) {
	            	var html = '其他';
	            	if(row.freeze==1){
	            		html = '冻结';
	            	}else if(row.freeze==2){
	            		html = '正常';
	            	}
	                return html ;
	            }
	        }]
	    }).on("click-row.bs.table", function (args, row, $element) {
	        
    });}
	

	 // 设置靓号
	function setAgentId(userId,nikeName,gameId){
		$("#niceName").html(nikeName);
		$("#gameId").html(gameId);
		$("#user_Id").val(userId);
		$(".alert").css('display', 'block');
	 }
	
	 function closeAlertClick() {
			$('.alert').css('display', 'none');
	 }
	 
	 function setStatus(userId,status){
	    	var msg = (status==1?"激活":"封禁") +" 该用户 ？";
	    	layer.confirm('确认'+msg, {
	    	    btn: ['确认','取消'], //按钮
	    	    shade: false //不显示遮罩
	    	}, function(){
	    	    $.post("${pageContext.request.contextPath}/admin/user_list_status.html",
	    	            {"userId":userId,"status":status},
	    	       function(data){
	    	            	var json = eval("("+data+")");
	    	            	$('#usersave').removeAttr("disabled");  //移除disabled属性 
	    					if(json.statusCode =='200'){
	    						layer.msg(json.message, {icon: 1});
	    						setTimeout("query()",2000);
	    					}else{
		    					layer.msg(json.message, {shift: 6});
	    					}
	    	      });
	    	});
	   }
	 
	 function confirmAgentClick(){
		  var msg = "确认设置用户  [ "+$("#niceName").html()+" ] 的邀请人ID为 "+$("#pgameId").val()+"？ ";
	    	layer.confirm(msg, {
	    	    btn: ['确认','取消'], //按钮
	    	    shade: false //不显示遮罩
	    	}, function(){
	    	    $.post("${pageContext.request.contextPath}/admin/user_edit_parentId.html",
	    	            {"userId":$("#user_Id").val(),"pgameId":$("#pgameId").val()},
	    	       function(data){
	    	            	var json = eval("("+data+")");
	    	            	$('#usersave').removeAttr("disabled");  //移除disabled属性 
	    					if(json.statusCode =='200'){
	    						layer.msg(json.message , {icon: 1});
	    						$('.alert').css('display', 'none');
	    						setTimeout("query()",2000);
	    					}else{
		    					layer.msg(json.message, {shift: 6});
	    					}
	    	      });
	    	});
		  
	  }
	 
	 function unLock(gameUserId){
		 if(gameUserId==""){
			 layer.msg("该用户未下载游戏~");
			 return ;
		 }
    	var msg = "解锁该用户 ？";
    	layer.confirm('确认'+msg, {
    	    btn: ['确认','取消'], //按钮
    	    shade: false //不显示遮罩
    	}, function(){
    	    $.post("${pageContext.request.contextPath}/admin/player_unlock.html",
    	            {"gameUserId":gameUserId},
    	       function(data){
    	            	var json = eval("("+data+")");
    	            	$('#usersave').removeAttr("disabled");  //移除disabled属性 
    					if(json.statusCode =='200'){
    						layer.msg(json.message, {icon: 1});
    						setTimeout("query()",2000);
    					}else{
	    					layer.msg(json.message, {shift: 6});
    					}
    	      });
    	});
	 }
	 
	 
    $(function () {
    	query();
    	
    });

</script>
</html>